<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Models\Invite;
class InviteController extends BaseController
{
    /**
     * 初始化
     * RegisterController constructor.
     * @param Register $register
     */
    public function __construct(Invite $invite)
    {
        parent::__construct();
        $this->invite = $invite;
    }

    /**
     * 邀请链接
     */
    public function getInvite()
    {
        $memberinfo =  $this->invite->createInviteUrl();
        return view('home/tg/invite',compact('memberinfo'));
    }

    /**
     * 成功推广
     */
    public function getInvited()
    {
        $res = $this->invite->invited(request());
        return view('home/tg/success_invite',compact('res'));
    }

    public function getInvitjl(){
        return view('home.tg.invitejl');
    }

    /**
     * 成功邀请zxj
     */
    public function postZxjinvited(){

        //dd(request('keyword'));

        $res = $this->invite->invited(request());
        $num = $res->toArray()['total'];

        if(!empty($num)){

            $ajaxData = $res;

        }else{

            $ajaxData['status'] = 0;
            $ajaxData['msg'] = '没有此用户!';

        }

        echo json_encode($ajaxData);

    }


}
